<?php

class IndexAction extends Action {

    public function _initialize() {
        if (!$this->admin['user_id'] || $this->admin['isadmin']!=1) {
            $this->redirect('/Login/index');
        }
    }

    public function index() {
        $this->display();
    }

    public function setindex() {
        $model=new Model();
        $pre=C('DB_PREFIX');
        $serverinfo = PHP_OS.' / PHP v'.PHP_VERSION;
        $serverinfo .= @ini_get('safe_mode') ? ' Safe Mode' : NULL;
        $dbversion = $model->query("SELECT VERSION()");
        $dbversion = $dbversion['0']['VERSION()'];
        $dbsize = 0;
        $query = $model->query("SHOW TABLE STATUS LIKE '$pre%'", 'SILENT');
        foreach($query as $val) {
            $dbsize += $val['Data_length'] + $val['Index_length'];
        }
        $dbsize = $dbsize ? sizecount($dbsize) : "未知大小";

		$tongji=D('Tongji')->find();
		//dump($tongji);
		//echo D('Tongji')->getlastsql();
		$this->assign('tongji',$tongji);
        $this->assign('serverinfo',$serverinfo);
        $this->assign('dbversion',$dbversion);
        $this->assign('dbsize',$dbsize);
        $this->assign('position','首页');
        $this->display();
    }
}
?>